const units = [1000000000, 1000000, 1000];

const unitsMap = ['b', 'm', 'k'];

export const formatBigNum = (num) => {
  for (let i = 0, l = units.length; i < l; i++) {
    if (num >= units[i]) {
      return `${num / units[i]}${unitsMap[i]}`;
    }
  }

  return num;
};

export const formatTag = (item, index, type) => {
  let tagObj = {}
  switch (type) {
    case 'rank':
      tagObj.isShow = index <= 2 
      tagObj.desc = index <= 2 ? `TOP ${index+1}` : null
      break;
    default:
      break;
  }
  
  return tagObj;
};